#!/bin/bash

echo "🔧 安装CORS依赖..."

# 检查是否已安装flask-cors
if pip show flask-cors > /dev/null 2>&1; then
    echo "✅ flask-cors 已安装"
else
    echo "📦 安装 flask-cors..."
    pip install flask-cors
fi

# 检查是否已安装flask
if pip show flask > /dev/null 2>&1; then
    echo "✅ flask 已安装"
else
    echo "📦 安装 flask..."
    pip install flask
fi

echo "✅ CORS依赖安装完成！"

echo ""
echo "📋 接下来需要做的："
echo "1. 更新nginx配置文件"
echo "2. 重启nginx服务"
echo "3. 重启Flask应用"
echo ""
echo "🔧 更新nginx配置："
echo "sudo cp nginx_config_cors.conf /etc/nginx/sites-available/aiservice.chasingbrilliant.com"
echo "sudo nginx -t"
echo "sudo systemctl reload nginx"
echo ""
echo "🔄 重启Flask应用："
echo "sudo systemctl restart ai-service" 